
#include <stdio.h>
#include <netinet/in.h>
#include <time.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>


int main()
{
	int sockfd;
	int maxfd= sockfd;
	fd_set readset;
	struct sockaddr_in  server_sock_addr;
	int addrlen=sizeof(struct sockaddr);

	if((sockfd=socket(AF_INET,SOCK_STREAM,0))==-1)
	{
		perror("socket");
		return -1;
	}

	bzero(&server_sock_addr,sizeof(struct  sockaddr_in));
	server_sock_addr.sin_family =AF_INET;
	server_sock_addr.sin_port = htons(7001);
	server_sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);


	if(bind(sockfd,(struct sockaddr *) &server_sock_addr, addrlen)==-1)
	{
		perror("bind");
		return -1;
	}
	if(listen(sockfd,5)==-1)
	{
		printf("listen failed\n");
		return -1;
	}


	FD_ZERO(&readset);
	FD_SET(sockfd,&readset);
	while(1)
	{
		if(select(maxfd+1,&readset,NULL,NULL,NULL)!=-1)
		{
			if(FD_ISSET(sockfd,&readset))
			{
				printf("new  connect");
			}
		}
	}

}
